<template>
  <div>
    <el-row :gutter="10" class="panel-group">
      <el-col :span="8">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-people">
            <img src="@/assets/images/home/sold.png" alt="" />
          </div>
          <div class="card-panel-description">
            <count-to
              :start-val="0"
              :end-val="saleGather.customerOppoTotal"
              :duration="2600"
              class="card-panel-num"
            />
            <div class="card-panel-text">集团客户总数</div>
          </div>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-message">
            <img src="@/assets/images/home/ask.png" alt="" />
          </div>
          <div class="card-panel-description">
            <count-to
              :start-val="0"
              :end-val="saleGather.oppoTotal"
              :duration="3000"
              class="card-panel-num"
            />
            <div class="card-panel-text">客户商机总数</div>
          </div>
        </div>
      </el-col>
      <!-- <el-col :span="6">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-money">
            <img src="@/assets/images/home/pay.png" alt="" />
          </div>
          <div class="card-panel-description">
            <count-to
              :start-val="0"
              :end-val="saleGather.customerContacts"
              :duration="3200"
              class="card-panel-num"
            />
            <div class="card-panel-text">客户干系人总数</div>
          </div>
        </div>
      </el-col> -->
      <el-col :span="8">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-shopping">
            <img src="@/assets/images/home/return.png" alt="" />
          </div>
          <div class="card-panel-description">
            <count-to
              :start-val="0"
              :end-val="saleGather.customerNoProduct"
              :duration="3600"
              class="card-panel-num"
            />
            <div class="card-panel-text">全国医院资源数</div>
          </div>
        </div>
      </el-col>
    </el-row>
    <el-row
      :gutter="5"
      class="panel-group"
      style="white-space: nowrap; overflow: scroll"
    >
      <el-col
        style="width: 20%"
        v-for="item in opportunityCompany"
        :key="item.fullName"
      >
        <div class="card-panel">
          <el-row :gutter="10" class="elrowStyle">
            <!-- <el-col :span="12">
              <div class="card-panel-icon-wrapper icon-people imgBox">
                <img src="@/assets/images/home/ask.png" alt="" />
              </div>
            </el-col> -->
            <el-col :span="10">
              <span>日总数:</span>
              <count-to
                :start-val="0"
                :end-val="item.dayTotal"
                :duration="2600"
                class="card-panel-num"
              /><br />
              <span>月总数:</span>
              <count-to
                :start-val="0"
                :end-val="item.monthTotal"
                :duration="2600"
                class="card-panel-num"
              /><br />
              <span>全部总数:</span>
              <count-to
                :start-val="0"
                :end-val="item.allTotal"
                :duration="2600"
                class="card-panel-num"
              /><br /><br />
              <h3>{{ item.fullName }}</h3>
            </el-col></el-row
          >
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import CountTo from "vue-count-to";
import { saleGather, opportunityCompany } from "@/api/home";
export default {
  components: { CountTo },
  created() {
    this.getSaleGather();
    this.getOpportunityCompany();
  },
  data() {
    return {
      saleGather: {
        customerOppoTotal: null,
        oppoTotal: null,
        customerContacts: null,
        customerNoProduct: null,
      },
      opportunityCompany: [],
    };
  },
  methods: {
    // 首页商机汇总信息
    getSaleGather() {
      saleGather().then((res) => {
        this.saleGather = res.data;
      });
    },
    // 公司商机数据
    getOpportunityCompany() {
      opportunityCompany().then((res) => {
        this.opportunityCompany = res.data;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.panel-group {
  margin-bottom: 10px;
  .card-panel {
    min-width: 180px;
    border-radius: 4px;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 34px 25px;
    // background-image: url("@/assets/images/home/bg.png");
    background-size: cover;
    // background-position: center;
    .icon-people,
    .icon-message,
    .icon-money,
    .icon-shopping {
      width: 75px;
      height: 75px;
      text-align: center;
      line-height: 89px;
      border-radius: 50%;
      margin-right: 12px;
      flex-shrink: 0;
    }
  }

  .elrowStyle {
    min-width: 180px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .card-panel-num {
    font-size: 20px;
    font-weight: 600;
  }
  .card-panel-text {
    margin-top: 4px;
    font-size: 14px;
    color: #666;
  }
}
.icon-people {
  background: #f2ebfb;
}

.icon-message {
  background: #edf8fe;
}

.icon-money {
  background: #fef3ef;
}

.icon-shopping {
  background: #ffeff2;
}

.icon-people {
  color: #40c9c6;
}

.icon-message {
  color: #36a3f7;
}

.icon-money {
  color: #f4516c;
}

.icon-shopping {
  color: #34bfa3;
}
.card-panel-description {
  padding-top: 15px;
}
</style>